home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
Libraries
/
SAT 2.3.8
/
Demos
/
SATminimal demo ƒ
/
sMySprite.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-12-17
|
1KB
|
49 lines
#include "SAT.h"
Handle theSound;
FacePtr faces[6];
/* Prototypes */
void InitMySprite();
pascal void SetupMySprite (SpritePtr me);
pascal void HandleMySprite (SpritePtr me);
void InitMySprite()
{
int i;
theSound = SATGetSound(128); /*Preload the sound */
for (i=0; i<=5; i++)
faces[i] = SATGetFace(128+i); /* Preload all sprite faces */
}
/* Important! Callback routines (Setup, Handle, Hit) must be declared "pascal"! */
pascal void SetupMySprite (SpritePtr me)
{
me->mode = 0; /* Pick a valid face number */
me->speed.h = 2; /* Set the speed - only horizontal is used here */
me->task = HandleMySprite; /* Set a handling routine. MANDATORY! If nil, the sprite will self-destruct. */
}
pascal void HandleMySprite (SpritePtr me)
{
/* Choose face */
me->mode = (me->mode + 1) % 6;
me->face = faces[me->mode];
/* Move */
me->position.h = me->position.h + me->speed.h;
if (me->position.h > gSAT.offSizeH - 16)
{
me->speed.h = -2;
SATSoundPlay(theSound, 1, false);
};
if (me->position.h < -16)
{
me->speed.h = 2;
SATSoundPlay(theSound, 1, false);
};
}